package team.hyznrj.studentsys.entity;

import java.util.Date;

import org.springframework.util.StringUtils;

import team.hyznrj.studentsys.exception.DataIllegalException;
import team.hyznrj.studentsys.exception.DataNullException;

public class QualityAchievement extends QualityAchievementKey {
	@Override
	public String toString() {
		return "QualityAchievement [no=" + no + ", value=" + value + ", flag=" + flag + ", projectType=" + projectType
				+ ", createTime=" + createTime + "] --->"+super.toString();
	}
	public boolean isLegal(boolean insert) {
		if (!insert&&StringUtils.isEmpty(this.no)) {
			throw new DataNullException("id不能为空");
		}
		if (this.getAcademicYears() == null || this.getItem() == null) {
			throw new DataNullException("日期不能为空");
		}
		if(this.getItem()!=1&&this.getItem()!=2){
			throw new DataIllegalException("学期非法");
		}
		if (StringUtils.isEmpty(this.getProject())){
			throw new DataNullException("加分原因不能为空");
		}
		if(StringUtils.isEmpty(this.getProjectType())){
			throw new DataNullException("加分类型不能为空");
		}
		if(StringUtils.isEmpty(this.getSno())){
			throw new DataNullException("学号不能为空");
		}
		if(this.getCreateTime()==null){
			throw new DataNullException("日期不能为空");
		}
		return true;
	}
	@Override
	public Object clone() throws CloneNotSupportedException {
		QualityAchievement e = new QualityAchievement();
		e.setAcademicYears(getAcademicYears());
		e.setFlag(getFlag());
		e.setItem(getItem());
		e.setNo(getNo());
		e.setProject(getProject());
		e.setProjectType(getProjectType());
		e.setSno(getSno());
		e.setValue(getValue());
		e.setCreateTime(getCreateTime());
		return e;
	}

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column quality_achievement.no
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    private String no;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column quality_achievement.value
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    private Float value;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column quality_achievement.flag
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    private String flag;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column quality_achievement.project_type
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    private String projectType;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column quality_achievement.create_time
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    private Date createTime;

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column quality_achievement.no
     *
     * @return the value of quality_achievement.no
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public String getNo() {
        return no;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column quality_achievement.no
     *
     * @param no the value for quality_achievement.no
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public void setNo(String no) {
        this.no = no == null ? null : no.trim();
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column quality_achievement.value
     *
     * @return the value of quality_achievement.value
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public Float getValue() {
        return value;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column quality_achievement.value
     *
     * @param value the value for quality_achievement.value
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public void setValue(Float value) {
        this.value = value;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column quality_achievement.flag
     *
     * @return the value of quality_achievement.flag
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public String getFlag() {
        return flag;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column quality_achievement.flag
     *
     * @param flag the value for quality_achievement.flag
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public void setFlag(String flag) {
        this.flag = flag == null ? null : flag.trim();
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column quality_achievement.project_type
     *
     * @return the value of quality_achievement.project_type
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public String getProjectType() {
        return projectType;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column quality_achievement.project_type
     *
     * @param projectType the value for quality_achievement.project_type
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public void setProjectType(String projectType) {
        this.projectType = projectType == null ? null : projectType.trim();
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column quality_achievement.create_time
     *
     * @return the value of quality_achievement.create_time
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column quality_achievement.create_time
     *
     * @param createTime the value for quality_achievement.create_time
     *
     * @mbggenerated Tue Jul 31 14:04:52 CST 2018
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}